package com.auxgroup.hr.front.ws;

import java.math.BigDecimal;

import org.apache.commons.lang.StringUtils;

/** 
 * @author lvliuhao 
 * @version 创建时间：2018年6月1日 下午10:11:38 
 * soapXml请求构建类
 */
public class SoapXmlBuild {

	
	/**
	 * 构建审批请求的soapXml
	 * @param soapXml
	 * @param requestDTO
	 */
	public static void buildApprovalSoapXml(StringBuilder soapXml,ProcessApproveQueDTO requestDTO){
		soapXml.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"");
    	soapXml.append(" xmlns:c=\"http://xmlns.oracle.com/Enterprise/Tools/schemas/C_WFL_APPROVAL_RQST.V1\">");
    	soapXml.append("<soapenv:Header/>");
    	soapXml.append("<soapenv:Body>");
    	soapXml.append("<c:C_WFL_APPROVAL_RQST_HDR>");
    	soapXml.append("<c:C_WF_TYPE>");
    	soapXml.append(requestDTO.getC_WF_TYPE());
    	soapXml.append("</c:C_WF_TYPE>");
    	soapXml.append("<c:C_TRANSACTION_NBR>");
    	soapXml.append(requestDTO.getC_TRANSACTION_NBR());
    	soapXml.append("</c:C_TRANSACTION_NBR>");
    	soapXml.append("<c:C_ACTION_TYPE>");
    	soapXml.append(requestDTO.getC_ACTION_TYPE());
    	soapXml.append("</c:C_ACTION_TYPE>");
    	soapXml.append("<c:C_USERID>");
    	soapXml.append(requestDTO.getC_USERID());
    	soapXml.append("</c:C_USERID>");
    	soapXml.append("<c:C_COMMENTS>");
    	if(StringUtils.isNotBlank(requestDTO.getC_COMMENTS())){
    		soapXml.append(requestDTO.getC_COMMENTS());
    	}
    	soapXml.append("</c:C_COMMENTS>");
    	if(requestDTO.getAddUserids()!=null&&!requestDTO.getAddUserids().isEmpty()){
    		soapXml.append("<c:C_WFL_APPROVAL_RQST_DETAIL>");
    		for (String userid : requestDTO.getAddUserids()) {
    			soapXml.append("<c:C_ADD_USERID>");
            	soapXml.append(userid);
            	soapXml.append("</c:C_ADD_USERID>");
			}
        	soapXml.append("</c:C_WFL_APPROVAL_RQST_DETAIL>");
    	}
    	soapXml.append("</c:C_WFL_APPROVAL_RQST_HDR>");
    	soapXml.append("</soapenv:Body>");
    	soapXml.append("</soapenv:Envelope>");
	}
	
	/**
	 * 流程编号获取
	 * @param soapXml
	 */
	public static void buildGetTranNumSoapXml(StringBuilder soapXml){
		soapXml.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">");
		soapXml.append("<soapenv:Header/>");
		soapXml.append("<soapenv:Body/>");
		soapXml.append("</soapenv:Envelope>");
	}
	
	/**
	 * 构建流程申请
	 * @param soapXml
	 * @param reqDto
	 */
	public static void buildProcessApplySoapXml(StringBuilder soapXml,ProcessApplyQueDTO reqDto){
		soapXml.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"");
    	soapXml.append(" xmlns:w3s=\"http://xmlns.oracle.com/Enterprise/Tools/schemas/C_WFL_APPLY_RQST.V5\">");
    	soapXml.append("<soapenv:Header/>");
    	soapXml.append("<soapenv:Body>");
    	soapXml.append("<w3s:C_WFL_APPLY_RQST_HDR>");
    	soapXml.append("<w3s:C_WF_TYPE>");
    	soapXml.append(reqDto.getC_WF_TYPE());
    	soapXml.append("</w3s:C_WF_TYPE>");
    	soapXml.append("<w3s:C_TRANSACTION_NBR>");
    	soapXml.append(reqDto.getC_TRANSACTION_NBR());
    	soapXml.append("</w3s:C_TRANSACTION_NBR>");
    	soapXml.append("<w3s:C_ACTION_TYPE>");
    	soapXml.append(reqDto.getC_ACTION_TYPE());
    	soapXml.append("</w3s:C_ACTION_TYPE>");
    	soapXml.append("<w3s:C_USERID>");
    	soapXml.append(reqDto.getC_USERID());
    	soapXml.append("</w3s:C_USERID>");
    	soapXml.append("<w3s:C_COMMENTS>");
    	if(StringUtils.isNotBlank(reqDto.getC_COMMENTS())){
    		soapXml.append(reqDto.getC_COMMENTS());
    	}
    	soapXml.append("</w3s:C_COMMENTS>");
    	soapXml.append("</w3s:C_WFL_APPLY_RQST_HDR>");
    	soapXml.append("</soapenv:Body>");
    	soapXml.append("</soapenv:Envelope>");
	}
	
	public static void buildPayrollLoginSoapXml(StringBuilder soapXml, String emplid, String pwd) {
		soapXml.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"");
		soapXml.append(" xmlns:w3s=\"http://xmlns.oracle.com/Enterprise/Tools/schemas/C_PASSWORD_VERIFY_REQ.V1\">");
		soapXml.append("<soapenv:Header/>");
		soapXml.append("<soapenv:Body>");
		soapXml.append("<w3s:C_PASSWORD_VERIFY>");
		soapXml.append("<w3s:EMPLID>");
		soapXml.append(emplid);
		soapXml.append("</w3s:EMPLID>");
		soapXml.append("<w3s:PASSWORD>");
		soapXml.append(pwd);
		soapXml.append("</w3s:PASSWORD>");
		soapXml.append("</w3s:C_PASSWORD_VERIFY>");
		soapXml.append("</soapenv:Body>");
		soapXml.append("</soapenv:Envelope>");
	}
	/**
	 * 获取请假天数
	 * @param soapXml
	 */
	public static void buildLeavetimeSoapXml(StringBuilder soapXml,
											   String emplid, String leaveType, String applInfo,
											   String appDt, String acrossDay, String beginDt,
											   String leaDayA, String endDt, String leaDayB){
		soapXml.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"");
		soapXml.append(" xmlns:w3s=\"http://xmlns.oracle.com/Enterprise/Tools/schemas/C_CAL_LEAVE_REQ.V2\">");
		soapXml.append("<soapenv:Header/>");
		soapXml.append("<soapenv:Body>");
		soapXml.append("<w3s:C_CAL_LEAVE_TIME>");
		soapXml.append("<w3s:C_WF_EMPLID>").append(emplid).append("</w3s:C_WF_EMPLID>");
		soapXml.append("<w3s:C_LEAVE_TYPE>").append(leaveType).append("</w3s:C_LEAVE_TYPE>");
		soapXml.append("<w3s:C_APPL_INFO>").append(applInfo).append("</w3s:C_APPL_INFO>");
		soapXml.append("<w3s:C_WF_APP_DT>").append(appDt).append("</w3s:C_WF_APP_DT>");
		soapXml.append("<w3s:C_ACROSS_DAY>").append(acrossDay).append("</w3s:C_ACROSS_DAY>");
		soapXml.append("<w3s:BEGIN_DT>").append(beginDt).append("</w3s:BEGIN_DT>");
		soapXml.append("<w3s:C_LEA_DAYA>").append(leaDayA).append("</w3s:C_LEA_DAYA>");
		soapXml.append("<w3s:END_DT>").append(endDt).append("</w3s:END_DT>");
		soapXml.append("<w3s:C_LEA_DAYB>").append(leaDayB).append("</w3s:C_LEA_DAYB>");
		soapXml.append("</w3s:C_CAL_LEAVE_TIME>");
		soapXml.append("</soapenv:Body>");
		soapXml.append("</soapenv:Envelope>");
	}




	/**
	 * 获取假期剩余天数
	 * @param soapXml
	 */
	public static void buildGetLeavebalSoapXml(StringBuilder soapXml,String emplId){
		soapXml.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"");
		soapXml.append(" xmlns:c=\"http://xmlns.oracle.com/Enterprise/Tools/schemas/C_GET_LEAVEBAL_RQST.V1\">");
		soapXml.append("<soapenv:Header/>");
		soapXml.append("<soapenv:Body>");
		soapXml.append("<c:EMPLID>");
		soapXml.append(emplId);
		soapXml.append("</c:EMPLID>");
		soapXml.append("</soapenv:Body>");
		soapXml.append("</soapenv:Envelope>");
	}
	
	/**
	 * 构建发短信的WS请求
	 * @param soapXml
	 * @param emplId
	 * @param mobileNum
	 */
	public static void buildSendMobildMsg(StringBuilder soapXml,String emplId,String mobileNum){
		soapXml.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"");
		soapXml.append(" xmlns:c=\"http://xmlns.oracle.com/Enterprise/Tools/schemas/C_MESSAGE_WS_REQ.V1\" ");
		soapXml.append(" xmlns:c1=\"http://xmlns.oracle.com/Enterprise/Tools/schemas/C_MESSAGE_REQ.V2\">");
		soapXml.append("<soapenv:Header/>");
		soapXml.append("<soapenv:Body>");
		soapXml.append("<c:C_MESSAGE_WS_REQ>");
		soapXml.append("<c:C_MESSAGE_REQ>");
		soapXml.append("<c1:C_MESSAGE_REQ class=\"R\">");
		soapXml.append("<c1:EMPLID>");
		soapXml.append(emplId);
		soapXml.append("</c1:EMPLID>");
		soapXml.append("<c1:PHONE>");
		soapXml.append(mobileNum);
		soapXml.append("</c1:PHONE>");
		soapXml.append("</c1:C_MESSAGE_REQ>");
		soapXml.append("</c:C_MESSAGE_REQ>");
		soapXml.append("</c:C_MESSAGE_WS_REQ>");
		soapXml.append("</soapenv:Body>");
		soapXml.append("</soapenv:Envelope>");
	}
	
	
	/**
	 * 构建班次名称获取
	 * @param soapXml
	 * @param emplId
	 * @param dateDay
	 */
	public static void buildGetClassName(StringBuilder soapXml,String emplId,String dateDay){
		soapXml.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" ");
		soapXml.append("xmlns:c=\"http://xmlns.oracle.com/Enterprise/Tools/schemas/C_GET_SCHED_RQST.V1\">");
		soapXml.append("<soapenv:Header/>");
		soapXml.append("<soapenv:Body>");
		soapXml.append("<c:EMP_SCHED_RQST_DATA>");
		soapXml.append("<c:EMPLID>");
		soapXml.append(emplId);
		soapXml.append("</c:EMPLID>");
		soapXml.append("<c:DATE_DAY>");
		soapXml.append(dateDay);
		soapXml.append("</c:DATE_DAY>");
		soapXml.append("</c:EMP_SCHED_RQST_DATA>");
		soapXml.append("</soapenv:Body>");
		soapXml.append("</soapenv:Envelope>");
	}
	
	public static void buildEvaPoint(StringBuilder soapXml,String docid){
		soapXml.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" ");
		soapXml.append("xmlns:c=\"http://xmlns.oracle.com/Enterprise/Tools/schemas/C_EVA_POINT_REQ.v1\">");
		soapXml.append("<soapenv:Header/>");
		soapXml.append("<soapenv:Body>");
		soapXml.append("<c:C_EVA_POINT_REQ>");
		soapXml.append("<c:MsgData>");
		soapXml.append("<c:Transaction>");
		soapXml.append("<c:C_EVA_POINT_REQ class=\"R\">");
		soapXml.append("<c:C_EVA_DOC_ID>");
		soapXml.append(docid);
		soapXml.append("</c:C_EVA_DOC_ID>");
		soapXml.append("</c:C_EVA_POINT_REQ>");
		soapXml.append("</c:Transaction>");
		soapXml.append("</c:MsgData>");
		soapXml.append("</c:C_EVA_POINT_REQ>");
		soapXml.append("</soapenv:Body>");
		soapXml.append("</soapenv:Envelope>");
	}
	
	
	public static void buildEpPlan(StringBuilder soapXml,String appraisalId,String version,
			String seqnbr,String oprid,String emplid,String action,String comments){
		soapXml.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" ");
		soapXml.append("xmlns:c=\"http://xmlns.oracle.com/Enterprise/Tools/schemas/C_EP_APP_REQ.V1\"> ");
		soapXml.append("<soapenv:Header/>");
		soapXml.append("<soapenv:Body>");
		soapXml.append("<c:C_EP_APP_REQ>");
		soapXml.append("<c:C_EP_APPRAISAL_ID>");
		soapXml.append(appraisalId);
		soapXml.append("</c:C_EP_APPRAISAL_ID>");
		soapXml.append("<c:VERSION>");
		soapXml.append(version);
		soapXml.append("</c:VERSION>");
		soapXml.append("<c:SEQNBR>");
		soapXml.append(seqnbr);
		soapXml.append("</c:SEQNBR>");
		soapXml.append("<c:OPRID>");
		soapXml.append(oprid);
		soapXml.append("</c:OPRID>");
		soapXml.append("<c:EMPLID>");
		soapXml.append(emplid);
		soapXml.append("</c:EMPLID>");
		soapXml.append("<c:ACTION>");
		soapXml.append(action);
		soapXml.append("</c:ACTION>");
		soapXml.append("<c:COMMENTS>");
		soapXml.append(comments);
		soapXml.append("</c:COMMENTS>");
		soapXml.append("</c:C_EP_APP_REQ>");
		soapXml.append("</soapenv:Body>");
		soapXml.append("</soapenv:Envelope>");
	}
	
	public static void buildCalcPoint(StringBuilder soapXml,String docid,String version,String emplid){
		soapXml.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" ");
		soapXml.append("xmlns:c=\"http://xmlns.oracle.com/Enterprise/Tools/schemas/C_EP_EVALUATE_R.v1\">");
		soapXml.append("<soapenv:Header/>");
		soapXml.append("<soapenv:Body>");
		soapXml.append("<c:C_EP_EVALUATE_R>");
		soapXml.append("<c:MsgData>");
		soapXml.append("<c:Transaction>");
		soapXml.append("<c:C_EP_EVALUATE_R class=\"R\" >");
		soapXml.append("<c:C_EP_APPRAISAL_ID>");
		soapXml.append(docid);
		soapXml.append("</c:C_EP_APPRAISAL_ID>");
		soapXml.append("<c:VERSION>");
		soapXml.append(version);
		soapXml.append("</c:VERSION>");
		soapXml.append("<c:EMPLID>");
		soapXml.append(emplid);
		soapXml.append("</c:EMPLID>");
		soapXml.append("</c:C_EP_EVALUATE_R>");
		soapXml.append("</c:Transaction>");
		soapXml.append("</c:MsgData>");
		soapXml.append("</c:C_EP_EVALUATE_R>");
		soapXml.append("</soapenv:Body>");
		soapXml.append("</soapenv:Envelope>");
	}
	
	
	public static void buildEpStatus(StringBuilder soapXml,String docid,String version){
		soapXml.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" ");
		soapXml.append("xmlns:c=\"http://xmlns.oracle.com/Enterprise/Tools/schemas/C_EP_STATUS_R.v1\">");
		soapXml.append("<soapenv:Header/>");
		soapXml.append("<soapenv:Body>");
		soapXml.append("<c:C_EP_STATUS_R>");
		soapXml.append("<c:MsgData>");
		soapXml.append("<c:Transaction>");
		soapXml.append("<c:C_EP_STATUS_R class=\"R\" >");
		soapXml.append("<c:C_EP_APPRAISAL_ID>");
		soapXml.append(docid);
		soapXml.append("</c:C_EP_APPRAISAL_ID>");
		soapXml.append("<c:VERSION>");
		soapXml.append(version);
		soapXml.append("</c:VERSION>");
		soapXml.append("</c:C_EP_STATUS_R>");
		soapXml.append("</c:Transaction>");
		soapXml.append("</c:MsgData>");
		soapXml.append("</c:C_EP_STATUS_R>");
		soapXml.append("</soapenv:Body>");
		soapXml.append("</soapenv:Envelope>");
	}
	
	
	public static void buildRankRequest(StringBuilder soapXml,String ProgramId,String calendarId,String periodId,String rankGroup,String evaType){
		soapXml.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" ");
		soapXml.append("xmlns:c=\"http://xmlns.oracle.com/Enterprise/Tools/schemas/C_EP_RANK_WS_REQ.V2\" ");
		soapXml.append("xmlns:c1=\"http://xmlns.oracle.com/Enterprise/Tools/schemas/C_EP_RANK_REQ.V2\"> ");
		soapXml.append("<soapenv:Header/>");
		soapXml.append("<soapenv:Body>");
		soapXml.append("<c:C_EP_RANK_WS_REQ>");
		soapXml.append("<c:C_EP_RANK_REQ>");
		soapXml.append("<c1:C_RANK_REQ class=\"R\">");
		soapXml.append("<c1:C_EP_PROGRAM_ID>");
		soapXml.append(ProgramId);
		soapXml.append("</c1:C_EP_PROGRAM_ID>");
		soapXml.append("<c1:C_EP_CALENDAR_ID>");
		soapXml.append(calendarId);
		soapXml.append("</c1:C_EP_CALENDAR_ID>");
		soapXml.append("<c1:C_EP_PERIOD_ID>");
		soapXml.append(periodId);
		soapXml.append("</c1:C_EP_PERIOD_ID>");
		soapXml.append("<c1:C_EP_RANK_GROUP>");
		soapXml.append(rankGroup);
		soapXml.append("</c1:C_EP_RANK_GROUP>");
		soapXml.append("<c1:C_EVA_TYPE>");
		soapXml.append(evaType);
		soapXml.append("</c1:C_EVA_TYPE>");
		soapXml.append("</c1:C_RANK_REQ>");
		soapXml.append("</c:C_EP_RANK_REQ>");
		soapXml.append("</c:C_EP_RANK_WS_REQ>");
		soapXml.append("</soapenv:Body>");
		soapXml.append("</soapenv:Envelope>");
	}
	
	
	public static void buildWfWsRequest(StringBuilder soapXml,String ProgramId,String template,String calendarId,
			String periodId,String rankGroup,String method,String emplid){
		soapXml.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" ");
		soapXml.append("xmlns:c=\"http://xmlns.oracle.com/Enterprise/Tools/schemas/C_EP_WF_WS_REQ.V1\" ");
		soapXml.append("xmlns:c1=\"http://xmlns.oracle.com/Enterprise/Tools/schemas/C_EP_WF_REQ.V1\">");
		soapXml.append("<soapenv:Header/>");
		soapXml.append("<soapenv:Body>");
		soapXml.append("<c:C_EP_WF_WS_REQ>");
		soapXml.append("<c:C_EP_WF_REQ>");
		soapXml.append("<c1:C_EP_WF_REQ class=\"R\">");
		soapXml.append("<c1:C_EP_PROGRAM_ID>");
		soapXml.append(ProgramId);
		soapXml.append("</c1:C_EP_PROGRAM_ID>");
		soapXml.append("<c1:C_EP_TEMPLATE>");
		soapXml.append(template);
		soapXml.append("</c1:C_EP_TEMPLATE>");
		soapXml.append("<c1:C_EP_CALENDAR_ID>");
		soapXml.append(calendarId);
		soapXml.append("</c1:C_EP_CALENDAR_ID>");
		soapXml.append("<c1:C_EP_PERIOD_ID>");
		soapXml.append(periodId);
		soapXml.append("</c1:C_EP_PERIOD_ID>");
		soapXml.append("<c1:C_EP_METHOD>");
		soapXml.append(method);
		soapXml.append("</c1:C_EP_METHOD>");
		soapXml.append("<c1:C_EP_RANK_GROUP>");
		soapXml.append(rankGroup);
		soapXml.append("</c1:C_EP_RANK_GROUP>");
		soapXml.append("<c1:SEQNBR></c1:SEQNBR>");
		soapXml.append("<c1:EMPLID>");
		soapXml.append(emplid);
		soapXml.append("</c1:EMPLID>");
		soapXml.append("</c1:C_EP_WF_REQ>");
		soapXml.append("</c:C_EP_WF_REQ>");
		soapXml.append("</c:C_EP_WF_WS_REQ>");
		soapXml.append("</soapenv:Body>");
		soapXml.append("</soapenv:Envelope>");
	}
	
	
	
	
	public static void buildEpIntrvwRequest(StringBuilder soapXml,String docid,String version,BigDecimal seqnbr,String emplid,String action){
		soapXml.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" ");
		soapXml.append("xmlns:c=\"http://xmlns.oracle.com/Enterprise/Tools/schemas/C_EP_INTRVW_WS_REQ.V1\" ");
		soapXml.append("xmlns:c1=\"http://xmlns.oracle.com/Enterprise/Tools/schemas/C_EP_INTRVW_REQ.V1\">");
		soapXml.append("<soapenv:Header/>");
		soapXml.append("<soapenv:Body>");
		soapXml.append("<c:C_EP_INTRVW_WS_REQ>");
		soapXml.append("<c:C_EP_INTRVW_REQ>");
		soapXml.append("<c1:C_EP_INTRVW_REQ class=\"R\">");
		soapXml.append("<c1:C_EP_APPRAISAL_ID>");
		soapXml.append(docid);
		soapXml.append("</c1:C_EP_APPRAISAL_ID>");
		soapXml.append("<c1:VERSION>");
		soapXml.append(version);
		soapXml.append("</c1:VERSION>");
		if(seqnbr!=null){
			soapXml.append("<c1:SEQNBR>");
			soapXml.append(seqnbr.toString());
			soapXml.append("</c1:SEQNBR>");
		}else{
			soapXml.append("<c1:SEQNBR></c1:SEQNBR>");
		}
		soapXml.append("<c1:EMPLID>");
		soapXml.append(emplid);
		soapXml.append("</c1:EMPLID>");
		soapXml.append("<c1:ACTION>");
		soapXml.append(action);
		soapXml.append("</c1:ACTION>");
		soapXml.append("</c1:C_EP_INTRVW_REQ>");
		soapXml.append("</c:C_EP_INTRVW_REQ>");
		soapXml.append("</c:C_EP_INTRVW_WS_REQ>");
		soapXml.append("</soapenv:Body>");
		soapXml.append("</soapenv:Envelope>");
	}
	
	
}
 